﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;

namespace ObjectOuster
{
    public static class SoundManager
    {
 /*       private static bool soundEffectsMuted = false;
        private static double soundEffectsVolume = 0.5;
        private static Dictionary<SoundEffect, MediaElement> soundEffectTable = new Dictionary<SoundEffect, MediaElement>();
        private static void ApplySoundEffectsVolume()
        {
            foreach (MediaElement element in soundEffectTable.Values)
            {
                element.Volume = soundEffectsVolume;
            }
        }
        private static void ApplySoundEffectsMuted()
        {
            if (soundEffectsMuted)
            {
                foreach (MediaElement element in soundEffectTable.Values)
                {
                    element.Stop();
                }
            }
        }
        public static double SoundEffectsVolume
        {
            get
            {
                return soundEffectsVolume;
            }
            set
            {
                soundEffectsVolume = value;
                ApplySoundEffectsVolume();
            }
        }
        public static bool SoundEffectsMuted
        {
            get
            {
                return soundEffectsMuted;
            }
            set
            {
                soundEffectsMuted = value;
                ApplySoundEffectsMuted();
            }
        }
        public static void SetSoundEffect(SoundEffect theSoundEffect, MediaElement theMediaElement)
        {
            if (soundEffectTable.ContainsKey(theSoundEffect))
            {
                soundEffectTable[theSoundEffect] = theMediaElement;
            }
            else
            {
                soundEffectTable.Add(theSoundEffect, theMediaElement);
            }
            ApplySoundEffectsVolume();
        }
        public static void PlaySoundEffect(SoundEffect theSoundEffect)
        {
            if (soundEffectTable.ContainsKey(theSoundEffect))
            {
                soundEffectTable[theSoundEffect].Stop();
                soundEffectTable[theSoundEffect].Play();
            }
        }

        private static bool musicEffectsMuted = false;
        private static double musicEffectsVolume = 0.5;
        private static List<MediaElement> musicEffectTable = new List<MediaElement>();
        private static Random musicEffectsRandomizer = new Random();
        private static void ApplyMusicEffectsVolume()
        {
            foreach (MediaElement element in musicEffectTable)
            {
                element.Volume = musicEffectsVolume;
            }
        }
        private static void ApplyMusicEffectsMuted()
        {
            if (musicEffectsMuted)
            {
                foreach (MediaElement element in musicEffectTable)
                {
                    element.Stop();
                }
            }
            else
            {
                PlayMusic();
            }
        }
        public static double MusicEffectsVolume
        {
            get
            {
                return musicEffectsVolume;
            }
            set
            {
                musicEffectsVolume = value;
                ApplyMusicEffectsVolume();
            }
        }
        public static bool MusicEffectsMuted
        {
            get
            {
                return musicEffectsMuted;
            }
            set
            {
                if (musicEffectsMuted != value)
                {
                    musicEffectsMuted = value;
                    ApplyMusicEffectsMuted();
                }
            }
        }
        public static void theMediaElement_MediaEnded(object sender, RoutedEventArgs e)
        {
            PlayMusic();
        }
        public static void AddMusic(MediaElement theMediaElement)
        {
            if (!musicEffectTable.Contains(theMediaElement))
            {
                musicEffectTable.Add(theMediaElement);
                theMediaElement.MediaEnded+=new RoutedEventHandler(theMediaElement_MediaEnded);
            }
        }
        public static void PlayMusic()
        {
            int musicEffect = musicEffectsRandomizer.Next(musicEffectTable.Count);
            musicEffectTable[musicEffect].Stop();
            musicEffectTable[musicEffect].Play();
        }*/

    }
}
